<?php

include_once $_SERVER['DOCUMENT_ROOT'] . "/functions/bdd/init.php";

function get_photo_principale($id) {
	$addr_no_photo = '';

	$bdd = bdd_init();

	$prep_get_photo = $bdd->prepare("SELECT * FROM images WHERE id_parent=? AND no_etape=0 ORDER BY no");
	$prep_get_photo->execute(array($id));

	if ($photo = $prep_get_photo->fetch()) {
		$prep_get_photo->closeCursor();
		return $photo['adresse'];
	} else {
		$prep_get_photo->closeCursor();
		return $addr_no_photo;
	}
}

?>
